#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;

#define len 10

/*****核心功能函数：冒泡排序*****/
int *BubbleSort(int list[len])
{
    bool status = false;
    while (!status)
    {
        status = true;
        for (int i = 0; i < len - 1; i++)
        {
            if (list[i] > list[i + 1])
            {
                int temp = list[i];
                list[i] = list[i + 1];
                list[i + 1] = temp;
                status = false;
            }
        }
    }
    return list;
}
/*****核心功能函数：冒泡排序*****/

/*****输出一个数组*****/
void print_array(int list[len])
{
    cout << "[";
    for (int i = 0; i < len - 1; i++)
    {
        cout << list[i] << ", ";
    }
    cout << list[len - 1] << "]"
         << "\n";
}
/*****输出一个数组*****/

/*****主函数*****/
int main()
{
    int list1[len] = {1, 5, 6, 2, 8, 4, 0, 9, 3, 7};
    print_array(list1);
    int *list1_sorted = BubbleSort(list1);
    print_array(list1_sorted);
    cout << "\n";

    int list2[len] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
    print_array(list2);
    int *list2_sorted = BubbleSort(list2);
    print_array(list2_sorted);
    cout << "\n";

    int list3[len] = {2, 0, 6, 6, 9, 8, 7, 5, 4, 5};
    print_array(list3);
    int *list3_sorted = BubbleSort(list3);   
    print_array(list3_sorted);
    cout << "\n";

    system("pause");
}
/*****主函数*****/